package Test1;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String snum = sc.nextLine();
        int num  = Integer.valueOf(snum);

        String[] str = new String[num];
        for (int j = 0; j < num; j++) {
            String s = sc.nextLine();
            str[j] = s;
        }
        int count = 0;
        for (int i = 0; i < str.length; i++) {
            String s = str[i];
            String[] strings = s.split(" ");
            if (strings[0].equals("L")){ //本地人判断
                   if (strings[1].equals("G") && strings[2].equals("C")) count++;
            }
            else if (strings[0].equals("T") && Integer.valueOf(strings[4])<=2){
                if (strings[1].equals("G") && strings[2].equals("C") && strings[3].equals("N")) count++;
            }
        }
        System.out.println(count);
    }
}
